/**
 * 
 */
package com.wubo.bm.common.acl;

import com.wubo.bm.common.entity.FeedBack;
import com.wubo.sec.SecurityManager;
import com.wubo.sec.acl.core.AclManager;
import com.wubo.sec.acl.core.EntityAcl;
import com.wubo.sec.core.UserData;

/**
 * @author WuBo
 * @CreateDate 2012-4-24 下午04:21:07
 */
public class FeedBackAcl extends EntityAcl {
	private FeedBack feedBack;
	
	public FeedBackAcl(FeedBack feedBack) {
		super();
		this.feedBack = feedBack;
	}

	@Override
	public int getAcl() {
		UserData user = SecurityManager.getCurrentUser();
		if(user == null){
			return AclManager.getInstance().getAcl("ACL_GET");
		}
		if(user.equals(feedBack.getUser())){
			return super.getAcl();
		}
		if(SecurityManager.isAdmin()){
			return super.getAcl();
		}
		return AclManager.getInstance().getAcl(new String[]{"ACL_GET", "ACL_ADD"});
	}
	
	/**
	 * 是否允许回复
	 * @return
	 */
	public boolean isAllowResponse(){
		UserData user = SecurityManager.getCurrentUser();
		if(user == null){
			return false;
		}
		if(user.equals(feedBack.getUser())){
			return false;
		}
		return true;
	}
}
